﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using TEL.ClientClasses;
using TEL.ClientClasses.SipInterfaces;

namespace TEL.TelPhoneF.Dialogs
{
    public partial class DialogOptions : TEL.TelPhoneF.Dialogs.DialogCustom
    {
        public DialogOptions()
        {
            InitializeComponent();
        }

        public object Options
        {
            get { return bindingOption.DataSource; }
            set { bindingOption.DataSource = value; }
        }

        private void DialogOptions_Load(object sender, EventArgs e)
        {
            comboAudioIn.DataSource = SipOperation.AudioInList();
            comboAudioOut.DataSource = SipOperation.AudioOutList();

            comboAudioIn.DisplayMember = "Name";
            comboAudioIn.ValueMember = "Index";

            comboAudioOut.DisplayMember = "Name";
            comboAudioOut.ValueMember = "Index";

            #region Transfer

            TransferType transferType = ((Options) bindingOption.Current).Transfer;
            switch (transferType)
            {
                case TransferType.Transfer:
                    radioTransfer.Checked = true;
                    break;
                case TransferType.Xfer:
                    radioXfer.Checked = true;
                    break;
            }

            #endregion
        }

       private  TransferType radioTransferType
        {
            get
            {
               if ( radioTransfer.Checked ) return TransferType.Transfer;
                return TransferType.Xfer;
            }
        }

        protected override void btnOK_Click(object sender, EventArgs e)
        {
            ((Options) bindingOption.Current).Transfer = radioTransferType;
        }

        private void trackBar1_MouseUp(object sender, MouseEventArgs e)
        {
            ClientClasses.SipOperation.TestSignalVolume(trackBar1.Value);
        }
    }
}